package com.sense.kukoo.biz_library.model

import com.sense.kukoo.biz_library.net.LibraryHttpApi
import com.sense.kukoo.common.media.net.MediaHttpApi
import com.sense.kukoo.common.mvvm.model.BaseMvvmModel
import com.sense.kukoo.common.repo.bean.*
import com.sense.kukoo.common.repo.http.KukooHttpManager

class SubscriptionsModel:BaseMvvmModel() {

    private val TAG: String = javaClass.simpleName
    override fun onModelCleared() {}

    suspend fun subscriptionQueryPage(pageIndex: Int, pageSize: Int): ResultBean<QueryPageBean<LibrarySubscriptionBean>> {
        return KukooHttpManager.instance
            .createHttpClient(LibraryHttpApi::class.java)
            .subscriptionQueryPage(""+pageIndex, ""+pageSize)
    }

    suspend fun subscriptionQueryItemPage(pageIndex: Int, pageSize: Int): ResultBean<QueryPageBean<BookItemBean>> {
        return KukooHttpManager.instance
            .createHttpClient(LibraryHttpApi::class.java)
            .subscriptionQueryItemPage(""+pageIndex, ""+pageSize)
    }

    suspend fun bookDetails(
        id: String
    ): ResultBean<BookDetailsBean> {
        return KukooHttpManager.instance.createHttpClient(MediaHttpApi::class.java).bookDetails(id)
    }

    suspend fun lightOff(id: String): ResultBean<Boolean> {
        return KukooHttpManager.instance.createHttpClient(LibraryHttpApi::class.java).lightOff(id)
    }
}